package org.jeecg.modules.crm.service.impl;

import org.jeecg.modules.crm.entity.Branch;
import org.jeecg.modules.crm.entity.BranchOverriding;
import org.jeecg.modules.crm.mapper.BranchOverridingMapper;
import org.jeecg.modules.crm.mapper.BranchMapper;
import org.jeecg.modules.crm.service.IBranchService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: Branch
 * @Author: jeecg-boot
 * @Date:   2025-04-11
 * @Version: V1.0
 */
@Service
public class BranchServiceImpl extends ServiceImpl<BranchMapper, Branch> implements IBranchService {

	@Autowired
	private BranchMapper branchMapper;
	@Autowired
	private BranchOverridingMapper branchOverridingMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		branchOverridingMapper.deleteByMainId(id);
		branchMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			branchOverridingMapper.deleteByMainId(id.toString());
			branchMapper.deleteById(id);
		}
	}
	
}
